--- title: "UCV2013H - Slick" created: 2025-11-28 tags: - 算法 --- # UCV2013H - Slick ## 题目 [UCV2013H - Slick](https://www.luogu.com.cn/problem/SP15436) ![[image-95c9eb32.png]] ## 思路分析 额外维护一个面积 应该可以用map来做 真的是写一题骂一次洛谷 显示个勾八 Unknown error 交题解代码也是这b样 ## 代码实现 ```cpp #include using namespace std; #define endl '\n' typedef pair PII; const int N=255; int g[N][N]; int n,m; bool st[N][N]; int cnt; map Hash; int dx[4]={-1,0,1,0}; int dy[4]={0,1,0,-1}; bool isVaild(int x,int y){ return x>=0 && x<=n-1 && y>=0 && y<=m-1 && !st[x][y]; } void bfs(int x,int y){ queue q; st[x][y]=true; q.push({x,y}); int Size=0; while(q.size()){ auto cur=q.front();q.pop(); int ux=cur.first,uy=cur.second; Size++; for(int i=0;i<4;i++){ int nx=ux+dx[i],ny=uy+dy[i]; if(isVaild(nx,ny) && g[nx][ny]==1){ st[nx][ny]=true; q.push({nx,ny}); } } } Hash[Size]++; } int main() { ios::sync_with_stdio(0),cin.tie(0),cout.tie(0); while(cin>>n>>m,n,m){ for(int i=0;i>g[i][j]; } } cnt=0; Hash.clear(); memset(st,false,sizeof st); for(int i=0;i